-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: add a lot of linting #1
Conversation
useEffect(() => { | ||
localStorage.setItem('favorites', JSON.stringify(favorites)); | ||
localStorage.setItem("favorites", JSON.stringify(favorites)); | ||
}, [favorites]); | ||
|
||
const handleFavorite = (book) => { | ||
const handleFavorite = (book: Book_t) => { | ||
setFavorites((prevFavorites) => { | ||
const isAlreadyFavorite = prevFavorites.some(f => f.id === book.id); | ||
const isAlreadyFavorite = prevFavorites.some( | ||
(f: Book_t) => f.id === book.id, | ||
); | ||
const updatedFavorites = isAlreadyFavorite | ||
? prevFavorites.filter(f => f.id !== book.id) | ||
? prevFavorites.filter((f: Book_t) => f.id !== book.id) | ||
: [...prevFavorites, book]; | ||
localStorage.setItem('favorites', JSON.stringify(updatedFavorites)); | ||
localStorage.setItem("favorites", JSON.stringify(updatedFavorites)); | ||
return updatedFavorites; | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
po co jest ten useEffect na górze, skoro niżej wstawiasz rzeczy do local storage'u?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
widać chata gpt 😭, bo kodzik wygląda nie najgorzej
good job Dawid, spisałeś się
const isAlreadyFavorite = prevFavorites.some( | ||
(f: Book_t) => f.id === book.id, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nie potrzebujesz tu adnotacji
const isAlreadyFavorite = prevFavorites.some( | |
(f: Book_t) => f.id === book.id, | |
); | |
const isAlreadyFavorite = prevFavorites.some( | |
(f) => f.id === book.id, | |
); |
const handleFavoriteClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.stopPropagation(); | ||
handleFavorite(book); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byś nie musiał tego typować jakbyś to wrzucił bezpośrednio koło buttona
<button
className={styles.favorite_container}
onClick={(e) => {
e.stopPropagation();
handleFavorite(book);
}}
>
import styles from "../styles/book.module.css"; | ||
import type { BookProps } from "./appContext"; | ||
|
||
const Book = React.memo(function Book({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
te memo i tak nie zadziała tutaj 😭, lepiej je wyrzucić
export function toggleStringInList(string, list) { | ||
const DELAY = 300; | ||
|
||
export function toggleStringInList(string: string, list: string[]): string[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nie potrzebujesz tu typu
export function toggleStringInList(string: string, list: string[]): string[] { | |
export function toggleStringInList(string: string, list: string[]) { |
<div> | ||
{languages.map((clickedLanguage) => ( | ||
<button | ||
key={clickedLanguage} // Unique key prop added here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xd, dobry komentarz
<Book | ||
key={book.id} | ||
book={book} | ||
isFavorite={favorites.some((f: Book_t) => f.id === book.id)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFavorite={favorites.some((f: Book_t) => f.id === book.id)} | |
isFavorite={favorites.some((f) => f.id === book.id)} |
/> | ||
))} | ||
<div> | ||
{favoriteBooks.map((book: Book_t) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{favoriteBooks.map((book: Book_t) => ( | |
{favoriteBooks.map((book) => ( |
const savedFavoritesJSON = localStorage.getItem("favorites"); | ||
const savedFavorites = | ||
savedFavoritesJSON !== null | ||
? (JSON.parse(savedFavoritesJSON) as Book_t[]) | ||
: []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
czemu ładujesz to na nowo skoro masz z props'ów tablice favorites? nie mogłeś jej użyć?
No description provided.